/**
 * 
 */
package com.real.fact.web.sale.application;

import org.apache.commons.lang.Validate;

import com.globant.katari.core.application.Command;
import com.real.fact.web.sale.domain.Sale;
import com.real.fact.web.sale.domain.SaleRepository;

/**
 * Finds a sale by its id.
 *
 */
public class FindSaleCommand  implements Command<Sale> {

  private final SaleRepository saleRepository;
  
  private long saleId;

  public FindSaleCommand(final SaleRepository theSaleRepository) {
    Validate.notNull(theSaleRepository);
    saleRepository = theSaleRepository;
  }

  public Sale execute() {
    return saleRepository.findById(saleId) ;
  }
  
  public void setSaleId(final long theSaleId) {
   saleId = theSaleId;
  }
}
